package com.spider.admin.store.primary.model;

import com.spider.admin.conf.AgentSectionEnum;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.validation.annotation.Validated;

@Getter
@Setter
@Validated
@Entity
@Table(name = "t_agent_options")

@Accessors(chain = true)

@Data
@EqualsAndHashCode(callSuper = true)
public class AgentOption extends SuperVO {
    @Id
    @Column(name = "pid")
    private String pid;
    @Column(name = "section")
    @NotEmpty(message = "代理配置块不能为空", groups = {Save.class,Update.class})
    private String section;

    @Transient
    private String sectionName;

    public String getSectionName() {

        if (AgentSectionEnum.GOLBAL.getCode().equals(this.section)) {
            return AgentSectionEnum.GOLBAL.getMessage();
        }
        if (AgentSectionEnum.HTTP.getCode().equals(this.section)) {
            return AgentSectionEnum.HTTP.getMessage();
        }
        if (AgentSectionEnum.SERVER.getCode().equals(this.section)) {
            return AgentSectionEnum.SERVER.getMessage();
        }
        if (AgentSectionEnum.LOCATION.getCode().equals(this.section)) {
            return AgentSectionEnum.LOCATION.getMessage();
        }
        if (AgentSectionEnum.EVENTS.getCode().equals(this.section)) {
            return AgentSectionEnum.EVENTS.getMessage();
        }
        return null;
    }

    @Column(name = "option_item")
    @NotEmpty(message = "代理配置项不能为空", groups = {Save.class,Update.class})
    private String optionItem;
    @Column(name = "option_desc")
    private String optionDesc;
}
